/**
 * 测试用例导出
 *
 * Created by snowingsea on 2021/01/20.
 */
const JsonTestCasesExporter = require('./json-test-cases');
const TcfTestCasesExporter = require('./tcf-test-cases');
const YmlTestCasesExporter = require('./yml-test-cases');
const ExcelTestCasesExporter = require('./excel-test-cases');
const ExcelTestCasesExporterOf614 = require('./excel-test-cases-614');

/**
 * 获取测试用例导出器
 * @param {String} projectVersionId 项目版本id
 * @param {String} format 用例格式
 * @param {Object} locale 国际化
 * @param {Object} version 项目版本
 * @param {Object} project 项目
 * @param {Object} creator 用户
 * @return {Class}
 */
function getTestCaseExporter(
  projectVersionId,
  format,
  locale,
  version = null,
  project = null,
  creator = null,
  fileIds,
) {
  switch (format) {
    case 'xlsx-huicheng':
      return new ExcelTestCasesExporter(projectVersionId, locale, version, project, creator,
        fileIds);
    case 'xlsx':
      return new ExcelTestCasesExporter(projectVersionId, locale, version, project, creator,
        fileIds);
    case 'tcf':
      return new TcfTestCasesExporter(projectVersionId, locale, version, project, creator, fileIds);
    case 'yml':
      return new YmlTestCasesExporter(projectVersionId, locale, version, project, creator, fileIds);
    case 'xlsx-614':
      return new ExcelTestCasesExporterOf614(projectVersionId, locale, version, project, creator,
        fileIds);
    case 'srt':
    case 'srt-func':
    default:
      return new JsonTestCasesExporter(projectVersionId, locale, version, project, creator,
        fileIds, format === 'srt-func');
  }
}

/**
 * Export model definition object.
 */
module.exports = {
  getTestCaseExporter,
};
